#!/bin/bash

# Test some dog commands

. ./common

for i in 0 1 2; do
	_start_sheep $i
done

_wait_for_sheep 3

_cluster_format

$DOG vdi create test 1G

echo hello | $DOG vdi write test 4M 512
# kill the master gracefully
$DOG node kill 0
sleep 2
_wait_for_sheep_recovery 1
$DOG node list -p 7001

nr=2
for i in 3 4 0; do
	_start_sheep $i
	nr=$(($nr + 1))
	_wait_for_sheep $nr $i
done
_wait_for_sheep_recovery 0

$DOG vdi track test
$DOG vdi track -i 1 test
_vdi_list test
$DOG vdi list -r test | awk '{$7="MASKED";print $0}'

$DOG vdi check test
# clear the 'first' data block
dd if=/dev/zero of=$STORE/0/obj/007c2b2500000001 bs=1M count=4 > /dev/null 2>&1
$DOG vdi check test | sort | uniq
